<template>
	<view class="ceshai">
		<view class="topstart"></view>
		<view class="xxi">
			<view class="toux">
				<image
					src="https://wx.qlogo.cn/mmhead/KetjXWSVppsC03nrqQRHTuB1VLS74eelpc299x3V2oxOpzYcRFaRmQInNxhmibeGT5xts15LRIyE/0"
					mode="aspectFill"></image>
			</view>
			<view class="weidenglu" @click="denglumtk = true" v-if="!userInfo"> 未登录(点击登录) </view>
			<view class="idsjh" v-if="userInfo">
				<view class="id">
					{{userInfo.nikename}}
				</view>
				<view class="diz">
					{{userInfo.phone}}
				</view>
			</view>
		</view>
	</view>
	<view class="quanbuner">
		<view class="liyi" @click="history">
			<view class="liimg">
				<view class="imga">
					<image src="../../static/6024.png" mode=""></image>
				</view>
				<view class="imgtext"> 我的发布 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
		</view>
		<view class="liyi" @click="liulanji">
			<view class="liimg">
				<view class="imgba">
					<image src="../../static/zhengshu/jilju.png" mode=""></image>
				</view>
				<view class="imgtext"> 浏览记录 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
		</view>
		<view class="liyi" @click="collection">
			<view class="liimg">
				<view class="imgc">
					<image src="../../static/6021.png" mode=""></image>
				</view>
				<view class="imgtext"> 我的收藏 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
		</view>
		<view class="liyi" @click="vip">
			<view class="liimg">
				<view class="imgb">
					<image src="../../static/6023.png" mode=""></image>
				</view>
				<view class="imgtext"> VIP充值 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
		</view>
		<view class="liyi">
			<view class="liimg">
				<view class="imgeg">
					<image src="../../static/zhengshu/23359.png" mode=""></image>
				</view>
				<view class="imgtext"> 在线客服 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
			<button class="butt" open-type="contact" size="mini">
			</button>
		</view>
		<view class="liyi" @click="jief">
			<view class="liimg">
				<view class="imgeg">
					<image src="../../static/zhengshu/integral.png" mode=""></image>
				</view>
				<view class="imgtext"> 我的收益 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
		</view>
		<view class="liyi" @click="franchise">
			<view class="liimg">
				<view class="imge">
					<image src="../../static/6023.png" mode=""></image>
				</view>
				<view class="imgtext"> 合作加盟 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
		</view>
		<view class="liyi" @click="fengxianf">
			<view class="liimg">
				<view class="imge">
					<image src="../../static/3321.png" mode=""></image>
				</view>
				<view class="imgtext"> 我的推荐 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
		</view>
		<view class="liyi" @click="addada">
			<view class="liimg">
				<view class="imge">
					<image src="../../static/zhengshu/zcz.png" mode=""></image>
				</view>
				<view class="imgtext"> 设置 </view>
			</view>
			<view class="youbian">
				<image src="../../static/icon_back.png" mode=""></image>
			</view>
		</view>
	</view>
	<view class="dangchukuan" v-show="denglumtk">
		<view class="neirdeli">
			<view class="titlebiaoti"> 您还未登录,请先登录！ </view>
			<view class="qianqudenglu">
				<button class="getphonebtn" @click="danchukuan"> 关闭</button>
				<button class="getphonebtn" open-type="getPhoneNumber" @getphonenumber="bindGetUserInfo">
					微信快捷登录</button>
				<!-- <button class="getphonebtn" v-if="!wx" @click="bindGetUserInfo"> 微信快捷登录</button> -->
			</view>
			<view class="xiamian">
				<view class="yuedu">
					<image src="../../static/unaquna.png" v-if="duihao" mode="" @click="duihaa"></image>
					<image src="../../static/duihao.png" v-if="yuanqunaduig" mode="" @click="duihab"></image>
				</view>
				<view class="zhiti"> 我已阅读并同意 <view class="yogh" @click="handleOpenPrivacyContract"> 用户隐私协议、 </view>
					<view class="yiexsi" @click="handleOpenPrivacyContract"> 隐私协议 </view>
				</view>
			</view>
		</view>
	</view>
	<zdy-tabbar :current-page='4'></zdy-tabbar>
</template>
<script>
	import {
		newgetOpenId, //新的获取openID
		getMemberInfo
	} from "../../request/api.js"
	export default {
		data() {
			return {
				duihao: true,
				yuanqunaduig: false,
				imageURL: '../../static/m138.png',
				denglumtk: false, //前去登录模态框
				// show: false, //前去登录模态框
				mobile: '',
				code: null,
				infos: [],
				userInfo: null,
				show: true,
				detail: '',
				err: '',
				openId: '',
				jiamiinfo: {},
				wx: false
			}
		},
		onLoad() {
			let that = this
		},
		onShow() {
			// this.denglumtk = false
			if (uni.getStorageSync('userInfo')) {
				this.getInfo() //刷新信息
			} else {
				// this.logins()
				// this.loginsa()
			}
		},
		methods: {
			getInfo() {
				getMemberInfo().then(res => {
					console.log(res, '个人信息');
					uni.setStorageSync('userInfo', JSON.stringify(res.result));
					this.userInfo = res.result
				})
			},
			handleOpenPrivacyContract() {
				// 打开隐私协议页面
				wx.openPrivacyContract({
					success: () => {}, // 打开成功
					fail: () => {}, // 打开失败
					complete: () => {}
				})
			},
			duihaa() {
				this.duihao = false
				this.yuanqunaduig = true
			},
			duihab() {
				this.yuanqunaduig = false
				this.duihao = true
			},
			logins() {
				let that = this;
				console.log("微信平台");
				uni.login({
					success: res => {
						console.log(res, '2121');
						newgetOpenId({
							code: res.code
						}).then(responts => {
							console.log(responts, 'DENG');
							const infos = responts.result;
							if (responts.success) {
								uni.hideLoading();
								if (responts.result.token != null) {
									that.userInfo = infos.memberInfo
									uni.setStorageSync('userInfo', JSON.stringify(infos.memberInfo));
									uni.setStorageSync('token', infos.token);
									console.log(that.userInfo);
								} else {
									// that.denglumtk = true;
									console.log('dada');
								}
							} else {
								uni.hideLoading();
								uni.showToast({
									title: '获取用户信息' + responts.message,
									icon: 'none'
								});
							}
						}).catch(error => {
							console.log(error, '121');
						});
					}
				});
			},
			loginsa() {
				let that = this
				wx.showLoading({
					title: '登录中',
				})
				uni.login({
					success: res => {
						console.log(res, 'jjjj')
						newgetOpenId({
							code: res.code,
							data: that.jiamiinfo.encryptedData,
							iv: that.jiamiinfo.iv,
						}).then(responts => {
							console.log(responts);
							const infos = responts.result;
							if (responts.success) {
								uni.hideLoading()
								that.userInfo = responts.result.memberInfo
								uni.setStorageSync('userInfo', JSON.stringify(infos.memberInfo));
								uni.setStorageSync('token', infos.token);
								that.denglumtk = false
							} else {
								uni.hideLoading()
								uni.showToast({
									title: responts.message,
									icon: 'none'
								});
							}
						})
					}
				})
			},
			getuserinfo() {
				let that = this
				uni.getUserProfile({
					desc: "获取你的昵称、头像、地区和性别",
					success: function(res) {
						console.log(res, "成功")
						that.detail = res.userInfo
						that.show = false
					},
					fail: res => {
						console.log(res, "失败")
						//拒绝授权
						uni.showToast({
							title: '您拒绝了授权',
							icon: 'none'
						})
						return;
					}
				})
			},
			danchukuan() {
				console.log('收回');
				this.denglumtk = false
			},
			bindGetUserInfo(e) {
				let that = this;
				if (that.yuanqunaduig === false) {
					wx.showToast({
						title: '请勾选用户隐私协议、隐私协议',
						icon: 'none'
					});
					return;
				}
				// #ifdef APP
				uni.navigateTo({
					url: "./Sign"
				})
				// #endif
				// #ifdef MP-WEIXIN
				if (e.detail.errMsg != 'getPhoneNumber:ok') {
					wx.showToast({
						title: '您拒绝了授权',
						icon: 'none'
					});
					return;
				}
				console.log(e);
				that.jiamiinfo = e.detail;
				that.loginsa();
				// #endif
			},
			history() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/myposts/index'
				})
			},
			member() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/member/imember'
				})
			},
			funeng() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: "/pages/empowerment/EmpowerList/EmpowerList"
				})
			},
			franchise() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/franchise/index'
				})
			},
			follow() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/follow/index'
				})
			},
			collection() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/collection/index'
				})
			},
			addada() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/menu/shez'
				})
			},
			liulanji() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/myposts/liulan'
				})
			},
			vip() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/member/imember'
				})
			},
			jief() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/vip/jifen'
				})
			},
			fengxianf() {
				if (!this.showDl()) {
					return
				}
				uni.navigateTo({
					url: '/pages/fengxag/index'
				})
			},
			showDl() {
				if (!uni.getStorageSync('userInfo')) {
					setTimeout(() => {
						this.denglumtk = true
					}, 1500)
					return false
				} else {
					return true
				}
			}
		},
	}
</script>
<style>
	page {
		background-color: #FAFAFA;
	}
</style>
<style scoped lang="less">
	.yuedu {
		// width: 54rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		line-height: 100rpx;
	}

	.yuedu image {
		width: 30rpx;
		height: 30rpx;
	}

	.getphonebtn {
		// width: 100%;
		// height: 100%;
		width: 300rpx;
		height: 100rpx;
		background-color: #ff5d3d;
		// margin-top: 30rpx;
		font-size: 30rpx;
		display: flex;
		color: #FFFFFF;
		justify-content: center;
		align-items: center;
		border-radius: 50rpx;
		border: 1rpx solid #eee;
	}

	.dangchukuan {
		// opacity: 0.7;
		position: fixed;
		left: 50%;
		top: 50%;
		// transform: translate(-50%, -50%);
		z-index: 99999;

		.neirdeli {
			width: 700rpx;
			height: 500rpx;
			background-color: #FAFAFA;
			margin: 0 auto;
			// margin-top: 400rpx;
			position: absolute;
			// left: 0;
			// top: 0;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			border-radius: 20rpx;
			padding-bottom: 34rpx;
			box-sizing: border-box;
		}

		.titlebiaoti {
			width: 700rpx;
			height: 200rpx;
			text-align: center;
			font-size: 43rpx;
			line-height: 300rpx;
			// border-bottom: 2rpx solid #55ff00;
		}

		.qianqudenglu {
			width: 700rpx;
			height: 200rpx;
			text-align: center;
			display: flex;
			line-height: 200rpx;
			color: #FFFFFF;
			display: flex;
			align-items: center;
			border-radius: 20rpx;
		}
	}

	.yuedu {
		display: flex;
	}

	.xiamian {
		width: 700rpx;
		height: 100rpx;
		text-align: center;
		display: flex;
		line-height: 200rpx;
		color: #000000;
		display: flex;
		align-items: center;
		border-radius: 20rpx;
		padding-left: 34rpx;
		box-sizing: border-box;
	}

	.zhiti {
		height: 100rpx;
		display: flex;
		align-items: center;
		margin-left: 4rpx;
		font-size: 24rpx;
	}

	.yogh {
		color: #94e75d;
	}

	.yiexsi {
		color: #94e75d;
	}

	.topstart {
		height: var(--status-bar-height);
	}

	.ceshai {
		height: 375rpx;
		background: linear-gradient(22.43deg, #fafafa 0%, #fbe6e2 100%);
	}

	.quanbu {
		position: relative;
		left: 0;
		top: -30rpx;
	}

	.quanbu {
		background: #FAFAFA;
	}

	.xxi {
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		display: flex;
		padding-top: 150rpx;
		padding-left: 20rpx;
		box-sizing: border-box;
		align-items: center;

		.weidenglu {
			font-size: 36rpx;
		}

		.toux {
			width: 120rpx;
			height: 120rpx;
			background: #DEDEE8;
			border-radius: 100rpx;
			margin-right: 17rpx;
			margin-left: 24rpx;

			image {
				width: 120rpx;
				height: 120rpx;
				border-radius: 100rpx;
			}
		}

		.idsjh {
			.id {
				font-size: 36rpx;
				color: #2C3133;
			}

			.diz {
				font-size: 26rpx;
				color: #999999;
				margin-top: 16rpx;
			}
		}
	}

	.quanbuner {
		border-radius: 20rpx;
		margin: 0 20rpx;
		padding: 20rpx;
		background-color: #fff;
		padding-bottom: 200rpx;
	}

	.liyi {
		display: flex;
		background: #FFFFFF;
		justify-content: space-between;
		align-items: center;
		height: 130rpx;
		box-sizing: border-box;

		.liimg {
			display: flex;

			.imgtext {
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
				font-style: normal;
				text-transform: none;
				margin-left: 30rpx;
			}
		}

		.youbian {
			width: 11rpx;
			height: 20rpx;

			image {
				width: 11rpx;
				height: 20rpx;
			}
		}
	}

	.imga {
		width: 50rpx;
		height: 36rpx;

		image {
			width: 36rpx;
			height: 36rpx;
		}
	}

	.imgeg {
		width: 50rpx;
		height: 30rpx;

		image {
			width: 36rpx;
			height: 37.5rpx;
		}
	}

	.butt {
		position: absolute;
		width: 80%;
		height: 130rpx;
		// padding: 0 27rpx;
		box-sizing: border-box;
		background: rgba(255, 255, 255, 0);
	}

	button::after {
		border: none;
	}

	button {
		border: none !important;
		padding: 0;
		color: #333;
		background-color: #fff;
	}

	.imgba {
		width: 50rpx;
		height: 38rpx;

		image {
			width: 38rpx;
			height: 38rpx;
		}
	}

	.imgb {
		width: 50rpx;
		height: 31.5rpx;

		image {
			width: 42.5rpx;
			height: 31.5rpx;
		}
	}

	.imgc {
		width: 50rpx;
		height: 37rpx;

		image {
			width: 38rpx;
			height: 37rpx;
		}
	}

	.imgd {
		width: 50rpx;
		height: 33rpx;

		image {
			width: 37.5rpx;
			height: 33rpx;
		}
	}

	.imge {
		width: 50rpx;
		height: 30rpx;

		image {
			width: 41rpx;
			height: 30rpx;
		}
	}
</style>